// 
// author: lbfamous
// date: 2020-02-09

cc.Class({
    extends: cc.Component,

    properties: {

        RegainSpeed: 320,
        isRegaining :{
            default:false,
            visible:false
        }

    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},
    start() {
        
        // this.startLine();
    },

    startLine () {

        this.node.stopAllActions();
        this.node.runAction(cc.repeatForever(cc.moveBy(2,cc.p(0,-100))))
        this.isRegaining = false;
    },

    //- 收杆
    regainLine(){
        if(this.isRegaining)
            return;
        this.node.stopAllActions();

        let duration = Math.abs(this.node.y) / this.RegainSpeed;

        if(duration <5)
            duration = 5;

        this.node.runAction(cc.moveTo(duration,cc.v2(0,0)).easing(cc.easeSineIn()));
        this.isRegaining = true;

    }
    // update (dt) {},
});
